package com.guo.pet_store.admin.service;

import com.guo.pet_store.admin.dao.OrderRepository;
import com.guo.pet_store.admin.dao.PetRepository;
import com.guo.pet_store.admin.dao.UserRepository;
import com.guo.pet_store.admin.pojo.Order;
import com.guo.pet_store.admin.pojo.Pet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import javax.persistence.criteria.*;
import java.util.List;

@Service
public class OrderServiceImpl implements OrderService{
    @Autowired
    OrderRepository orderRepository;
    @Autowired
    UserRepository userRepository;
    @Override
    public List<Order> getOrder(Long userId) {
        return orderRepository.findOrdersByUser(userRepository.getOne(userId));
    }

    @Override
    public void saveOrder(Order order) {
        orderRepository.save(order);
    }
}
